<?php

use yii\helpers\Url;
use yii\widgets\Pjax;
use yii\widgets\LinkPager;
use backend\assets\AppAsset;
AppAsset::addCss($this , "/plugins/bootstrap-sweetalert/sweet-alert.css");
AppAsset::addScript($this , "/plugins/bootstrap-sweetalert/sweet-alert.min.js");
AppAsset::addScript($this , "/js/app.js");
$this->title = '导航列表';
?>
<div class="panel">
    <div class="panel-body">
        <div class="card-box">
            <div class="row">
                <div class="col-sm-6">
                    <div class="m-b-30">
                        <a href="<?=Url::toRoute('/nav/add')?>" class="btn btn-primary waves-effect waves-light">
                            添加导航
                            <i class="fa fa-plus"></i>
                        </a>
                    </div>
                </div>
            </div>
            <?php Pjax::begin(['id' => 'item-data-list']);?>
            <div class="">
                <div class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                    <div class="row">
                        <div class="col-sm-12">
                            <table class="table table-striped dataTable no-footer">
                                <thead>
                                <tr role="row">
                                    <th class="col-sm-2 sorting">标题</th>
                                    <th class="col-sm-2 sorting">描述</th>
                                    <th class="col-sm-2 sorting">链接</th>
                                    <th class="col-sm-2 sorting">状态</th>
                                    <th class="col-sm-2 sorting">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php foreach($data as $item):?>
                                    <tr class="gradeA odd">
                                        <td><?=mb_substr($item['title'],0,10,'utf-8').'...'?></td>
                                        <td><?=mb_substr($item['desc'],0,10,'utf-8').'...'?></td>
                                        <td><?=$item['url']?></td>
                                        <td>
                                            <?php
                                                switch($item['status'])
                                                {
                                                    case 1:echo "<a onclick='app.changeStatus(this);return false;' href='".Url::toRoute('/nav/change?id='.$item['id'])."' class='label label-primary'>启用</a>";break;
                                                    case 0:echo "<a onclick='app.changeStatus(this);return false;' href='".Url::toRoute('/nav/change?id='.$item['id'])."' class='label label-warning'>禁用</a>";break;
                                                }
                                            ?>
                                        <td class="actions">
                                            <a onclick="location.href=this.href" href="<?=Url::toRoute('/nav/add?id='.$item['id'])?>" class="on-default edit-row">
                                                <i class="fa fa-pencil"></i>
                                            </a>
                                            <a onclick="app.deleteData(this);return false;" href="<?=Url::toRoute('/nav/delete?id='.$item['id'])?>" class="on-default remove-row">
                                                <i class="fa fa-trash-o"></i>
                                            </a>
                                        </td>
                                    </tr>
                                <?php endforeach;?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <?php Pjax::end();?>
        </div>
    </div>
</div>
